package com.zheng.security.handles;

import com.zheng.security.exception.ApiException;
import com.zheng.security.utils.ApiResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zyq
 * @Description 自定义异常全局处理
 * @createTime 2021年01月15日 17:47:00
 */
@ControllerAdvice
public class ApiExceptionHandle {

    @ResponseBody
    @ExceptionHandler(value = ApiException.class)
    public ApiResponse handleException(ApiException exception){
        return ApiResponse.error(exception.getMessage());
    }


}
